package com.kanshu.ksgb.fastread.doudou.module.personal.adapter;

import android.content.Context;
import android.view.View;

import com.dl7.recycler.adapter.BaseQuickAdapter;
import com.dl7.recycler.adapter.BaseViewHolder;
import com.kanshu.ksgb.fastread.doudou.R;
import com.kanshu.ksgb.fastread.doudou.module.personal.bean.CashRecordInfo;

import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

public class CashRecordAdapter extends BaseQuickAdapter<CashRecordInfo> {

    public CashRecordAdapter(Context context, List<CashRecordInfo> data) {
        super(context, data);
    }

    @Override
    protected int attachLayoutRes() {
        return R.layout.item_encash_record_layout;
    }

    @Override
    protected void convert(BaseViewHolder holder, CashRecordInfo item, int position) {
        String preStr ;
        switch (item.getType()) {
            case "5":
                preStr = "- ";
                break;
            default:
                preStr = "+ ";
                break;
        }
        holder.getView(R.id.tvStatus).setVisibility(View.GONE);
        holder.setText(R.id.tvContent, item.getType_title());
        long time = Long.parseLong(item.getAdd_time())*1000;
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        holder.setText(R.id.tvDate, sdf.format(new Date(time)));
        int rmbF = Integer.parseInt(item.getRmb());
        holder.setText(R.id.tvAmount, preStr + new DecimalFormat("0.00").format(rmbF / 100.0));

    }

}
